<template>
	<view class="userinfo-content">
		<uni-forms ref="otherForm" :rules="otherFormRules" :modelValue="others" :label-width='75'>
			<uni-forms-item label="期望年龄" required name="age">
				<uni-easyinput v-model="others.age" type='number' placeholder="如:25" />
			</uni-forms-item>
			<uni-forms-item label="接受最小年龄" required name="minAge">
				<uni-easyinput v-model="others.minAge" type='number' placeholder="如:5" />
			</uni-forms-item>
			<uni-forms-item label="接受最大年龄" required name="maxAge">
				<uni-easyinput v-model="others.maxAge" type='number' placeholder="如:5" />
			</uni-forms-item>

			<uni-forms-item label="身高">
				<uni-easyinput v-model="others.height" placeholder="如:165-175" />
			</uni-forms-item>
			<uni-forms-item label="体重">
				<uni-easyinput v-model="others.kg" placeholder="如:45-75" />
			</uni-forms-item>
			<uni-forms-item label="是否高颜值">
				<uni-data-select v-model="others.face" :localdata="noHave"></uni-data-select>
			</uni-forms-item>
			<uni-forms-item label="要求学历">
				<uni-data-select v-model="others.education" :localdata="shcoolList"></uni-data-select>
			</uni-forms-item>
			<uni-forms-item label="婚姻要求" required name="needMarry">
				<uni-data-checkbox v-model="others.needMarry" :localdata="marryHistryItem" />
			</uni-forms-item>
			<uni-forms-item label="婚后是否要孩子" required name="needChild">
				<uni-data-checkbox v-model="others.needChild" :localdata="needchildList" />
			</uni-forms-item>
			<uni-forms-item label="房屋要求">
				<uni-data-select v-model="others.needHouse" :localdata="houseList"></uni-data-select>
			</uni-forms-item>
			<uni-forms-item label="车辆要求">
				<uni-data-select v-model="others.needCar" :localdata="noHave"></uni-data-select>
			</uni-forms-item>
			<uni-forms-item label="要求年收入">
				<view class="flx-auto">
					<uni-easyinput v-model="others.incoom" type='number' placeholder="7-8" />
					<view>万</view>
				</view>
			</uni-forms-item>
			<uni-forms-item label="有无贷款">
				<uni-data-select v-model="others.haveHouseMoney" :localdata="noHave"></uni-data-select>
			</uni-forms-item>
			<uni-forms-item label="期望描述" required name="hopeDes">
				<uni-easyinput type="textarea" v-model="others.hopeDes" placeholder="如:我希望是大眼睛" />
			</uni-forms-item>

			<view class="unisection">
				<view></view>
				<view>其他信息</view>
			</view>

			<uni-forms-item label="是否有保险">
				<uni-data-checkbox v-model="others.needInsure" :localdata="noHave" />
			</uni-forms-item>
			<uni-forms-item label="老家范围">
				<uni-data-checkbox v-model="others.homeArea" :localdata="homeAreaList" />
			</uni-forms-item>
			<uni-forms-item label="对家庭要求说明">
				<uni-data-select v-model="others.needHomeDesc" :localdata="homedescList"></uni-data-select>
			</uni-forms-item>
			<uni-forms-item label="对家庭要求补充">
				<uni-easyinput type="textarea" v-model="others.needHomeDescExite" placeholder="" />
			</uni-forms-item>


			<uni-forms-item label="不喜欢的职业">
				<uni-data-checkbox v-model="others.dontLikeJob" multiple :localdata="jobList" />
			</uni-forms-item>
			<uni-forms-item label="不喜欢工作性质">
				<uni-data-select v-model="others.dontLikeJobxz" pceholder="请选择"
					:localdata="jobxzList"></uni-data-select>
			</uni-forms-item>
			<uni-forms-item label="不喜欢的行为">
				<uni-easyinput type="textarea" v-model="others.dontLikeBehavior" placeholder="如:抽烟,酗酒" />
			</uni-forms-item>
		</uni-forms>

	</view>
</template>


<script setup lang="ts">
	import { ref } from 'vue';
	import emun from '@/utils';
	const otherForm = ref()

	const others = ref({
		age: '',
		minAge: '',
		maxAge: '',
		height: "",
		kg: '',
		face: '',
		education: '',
		needMarry: 0,
		needChild: 0,
		needHouse: '',
		needCar: '',
		incoom: '',
		haveHouseMoney: '',
		hopeDes: '',
		needInsure: '',
		homeArea: '',
		needHomeDesc: '',
		needHomeDescExite: '',
		dontLikeJob: '',
		dontLikeJobxz: '',
		dontLikeBehavior: ''
	})
	const otherFormRules = {
		age: {
			rules: [{
				required: true,
				errorMessage: '年龄不能为空'
			}]
		},
		minAge: {
			rules: [{
				required: true,
				errorMessage: '接受最小年龄不能为空'
			}]
		},
		maxAge: {
			rules: [{
				required: true,
				errorMessage: '接受最大年龄不能为空'
			}]
		},

		needMarry: {
			rules: [{
				required: true,
				errorMessage: '婚姻要求不能为空'
			}]
		},
		needChild: {
			rules: [{
				required: true,
				errorMessage: '婚后是否要孩子不能为空'
			}]
		},
		hopeDes: {
			rules: [{
				required: true,
				errorMessage: '期望描述不能为空'
			}]
		},

	}
	const commitData = () => {
		return new Promise((resolve, reject) => {
			otherForm.value.validate().then(res => {
				resolve(others)
			}).catch(err => {
				reject(err)
			})
		});

	}
	defineExpose({
		commitData,
		others
	})
	const noHave = ref(emun.noHave)
	const sexs = ref(emun.sexs)
	const marryHistryItem = ref(emun.marryHistryItem)
	const homedescList = ref(emun.homedescList)
	const homeAreaList = ref(emun.homeAreaList)

	const houseList = ref(emun.houseList)
	const needchildList = (emun.needchildList)
	const shcoolList = ref(emun.shcoolList)
	const jobList = ref(emun.jobList)
	const jobxzList = ref(emun.jobxzList)
</script>

<style lang="scss" scoped>
	.userinfo-content {
		padding: 48rpx 32rpx;

		.unisection {
			position: relative;
			display: flex;
			flex-direction: row;
			align-items: center;
			padding: 12px 10px;
			font-weight: normal;
			font-size: 28rpx;
			background: #eee;
			margin-bottom: 20px;
			padding-left: 8rpx;

		}
	}
</style>